<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="stylesheet" href="../../assets/css/layui.css">
    <link rel="stylesheet" href="../../assets/css/view.css"/>
</head>
<body class="layui-view-body">

<div class="layui-content">
    <div class="layui-row">
        <div class="layui-card">
            <div class="layui-card-header">添加快递员</div>

            <form class="layui-form layui-card-body" id="form">

                <div class="layui-form-item">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required" name="name" placeholder="请输入姓名"
                               required type="text">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">手机号码</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required" name="phone" placeholder="请输入手机号码"
                               required type="text">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">身份证号码</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required" name="idnumber" placeholder="请输入身份证号码"
                               required type="text">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="required" name="password" placeholder="请输入密码"
                               required type="password">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-blue" lay-filter="formDemo" lay-submit>立即提交</button>
                        <button class="layui-btn layui-btn-primary" type="reset">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="../../assets/layui.all.js"></script>
<script src="/admin/qrcode/jquery2.1.4.js"></script>
<script src="/admin/layer/layer.js"></script>
<script>
    var form = layui.form
        , layer = layui.layer;
</script>
<script>
    $(function () {
        $("#form").submit(function () {
            var windowId = layer.load();
            var name = $("input:eq(0)").val();
            var phone = $("input:eq(1)").val();
            var idnumber = $("input:eq(2)").val();
            var password = $("input:eq(3)").val();


            $.post("/EDelivery/insert.do", {
                    name: name,
                    phone: phone,
                    idnumber: idnumber,
                    password: password
                },
                function(data){
                    if (data.status == 0) {
                        layer.close(windowId);
                        layer.msg("录入成功");
                        $("input").val("");
                        return true;
                    } else {
                        layer.close(windowId);
                        layer.msg("录入失败");
                        return false;
                    }
            });

        });
    });
</script>
</body>
</html>
